 <!--
 * @Descripttion: 财务会记->财务报表->利润
 * @Author: GaoWei
 * @Date: 2021-04-25 12:11:55
 * @LastEditors: GaoWei
 * @LastEditTime: 2021-06-03 17:03:07
-->

<template>
  <div class="content-wrapper a-base-container">
    <div class="requisition-set-wrapper" style="border: 1px solid #ccc">
      <!-- 按钮 -->
      <div class="btn-wrapper clearfix" style="  border-bottom: 1px solid #ddd;">
        <a-row class="text-center clearfix">
          <a-col :xs="25" :sm="25" :md="25" :lg="16" :xl="12">
            <a-col :xs="2" :sm="2" :md="2" :lg="2" :xl="2" v-show="design">
              <div class="btns" @click="printOrder" style="display:block;margin-left:10px">
                <a-icon class="btns-icon" type="printer" />
                <div class="btns-text">打印</div>
              </div>
            </a-col>
            <a-col :xs="2" :sm="2" :md="2" :lg="2" :xl="2" v-show="design">
              <div style="position:relative">
                <div class="btns" style="display:block;margin-left:10px">
                  <a-icon class="btns-icon" type="form" />
                  <div class="btns-text" @click="gettabList">设计</div>
                </div>
              </div>
            </a-col>
            <!-- <a-col :xs="2" :sm="2" :md="2" :lg="2" :xl="2" v-show="design">
              <div style="position:relative">
                <div class="btns">
                  <a-icon class="btns-icon" type="download" />
                  <div class="btns-text">导出</div>
                </div>
              </div>
            </a-col> -->

            <a-col :xs="2" :sm="2" :md="2" :lg="2" :xl="2" v-show="preservtion">
              <div style="position:relative">
                <div class="btns" style="display:block;margin-left:10px;width:70px">
                  <a-icon class="btns-icon" type="save" />
                  <div class="btns-text" @click="gettabListq">保存</div>
                </div>
              </div>
            </a-col>

            <a-col :xs="2" :sm="2" :md="2" :lg="2" :xl="2" v-show="preservtion">
              <div style="position:relative">
                <div class="btns" style="display:block;margin-left:10px;width:70px">
                  <a-icon class="btns-icon" type="monitor" />
                  <div class="btns-text" @click="browse">浏览</div>
                </div>
              </div>
            </a-col>

            <a-col :xs="2" :sm="2" :md="2" :lg="2" :xl="2">
              <div style="position:relative" v-show="status">
                <div class="btns">
                  <a-icon class="btns-icon" type="monitor" />
                  <div class="btns-text" @click="showModal">查询</div>
                </div>
              </div>
            </a-col>
          </a-col>
        </a-row>
      </div>
      <!-- 设计表列表 -->

      <div ref="print" class="credentials-wrapper" v-show="show" style="margin-left:">
        <div class="tablePos">
          <!-- 表格航标 -->
          <div class="formula">
            <div class="formulaone">
              <input v-model="Trademark">
            </div>
            <div class="formulatow">
            </div>
            <div class="formulafreen">
              <input v-model="Rowvalue">
            </div>
            <div class="formuladiv"></div>
          </div>
          <!-- 表头 -->
          <table border="1" width="100%" style="border:1px solid #cacaca;border-bottom: 0px;">
            <tr class="toplist">
              <th v-for='(item,ind) in topList' :key="ind" :class="item == 'B' ? 'tableactive' : item == 'F' ? 'tableactives' : item == '' ? 'tableactiv' : 'publictableactive' ">{{item}}</th>
            </tr>
            <tr class="toplist">
              <td colspan="9">
                <div contenteditable='true' style="height: 50px; font-size: 23px;">{{listTitle}}</div>
                <div>
                  <!-- <div contenteditable='true' style="text-align: right;">企汇表：{{remarks}}表</div> -->
                  <div class="company">
                    <span class="company-span-one" contenteditable='true'>编制单位：{{company}}</span>
                    <span contenteditable='true'>时间：{{times}}</span>
                    <span class="company-span-tow" contenteditable='true'>企汇表：{{remarks}}表</span>
                    <!-- <span class="company-span-tow" contenteditable='true'>单位：{{unit}}元</span> -->
                  </div>
                </div>
              </td>
            </tr>
          </table>
          <!-- 表体 -->
          <a-table bordered :data-source="dataSource" :columns="columns" :customRow="customClick" :pagination="false" class="solto">
            <template v-for="item in slotArray" :slot="item" slot-scope="text, record,index">
              <editable-cell @runDataTale="runDataTale" @trademark="trademark" v-if="isRouterAlive" v-on:validate="validate" :text="text" :col="item" :record="record" :doindex="index"
                @change="onCellChange(index, item , $event)" />
            </template>
          </a-table>

        </div>
      </div>
      <!-- 预览表 -->
      <div ref="print" class="credentials-wrapper" v-show="showtow">
        <div class="tablePos">
          <table width="100%" style="border:0">
            <tr class="toplist">
              <td colspan="9">
                <div style="height: 50px; font-size: 23px;">{{listTitle}}</div>
                <div>
                  <!-- <div style="text-align: right;">企汇表：{{remarks}}表</div> -->
                  <div class="company">
                    <span class="company-span-one">编制单位：{{company}}</span>
                    <span>{{times}}</span>
                    <span class="company-span-tow">企汇表：{{remarks}}表</span>
                    <!-- <span class="company-span-tow">单位：{{unit}}元</span> -->
                  </div>
                </div>
              </td>
            </tr>
          </table>
          <a-table bordered :data-source="dataSource" :columns="column" :pagination="false">
          </a-table>
        </div>
      </div>

      <!-- 右键菜单 -->
      <div class="contextmenu-box">
        <ul v-show="nvmu" :style="{left:left+'px',top:top+'px'}" class="contextmenu">
          <li @click="handleAdd()">新增行</li>
          <li @click="handleDelete()">删除行</li>
        </ul>
      </div>
    </div>

    <!--用做横向打印-->
    <div v-html="stylePrint"></div>

    <!-- 查询弹窗 -->
    <div>
      <a-modal v-model="visibles" title="资产负债表查询">
        <template slot="footer">
          <a-button key="back" @click="handleCancel">
            关闭
          </a-button>
          <a-button key="submit" type="primary" :loading="loading" @click="handleOk">
            查询
          </a-button>
        </template>
        <div>
          <span>会计期间：</span>
          <span style="margin-left:12px">
            <a-date-picker format="YYYY-MM-DD" placeholder="请选择业务日期" @change="onChangeBusinessDate" v-model="dataTimes" />
          </span>
        </div>
        <br>
        <div>
          <span>未记账凭证：</span>
          <a-checkbox v-model="chebox">
          </a-checkbox>
        </div>
      </a-modal>
    </div>
  </div>
</template>

<script>
const dataSource = [];
// 调试表格显示
// for (var i = 1; i <= 10; i++) {
//   dataSource.push(
//     { 'id': i, 'Assets': '', 'LineNoOne': '', 'FinaltermOne': '', 'BeginningOne': '', 'Liabilities': '', 'LineNoTow': '', 'FinaltermTow': '', 'BeginningTow': '', }
//   );
// }

import editableCell from "@/components/Finance/liaBilitiesEdit/liaBilitiesEdit";
import { save, getFormulaList, getAssetsLiabilities, periodlist } from '@/api/finance/liablities/liablitieslist';
import searchGroupHeader from "@/components/PopUpLayer/searchGroupHeader";
import FormSearchGroup from '@/components/Form/FormSearchGroup';

export default {
  components: {
    editableCell,
    searchGroupHeader,
    FormSearchGroup,
  },

  data () {

    return {
      dataSourceLength: 40,//表格数量
      topList: ['', 'A', 'B', 'C', 'D'],    //表头领标
      topLists: ['A', 'B', 'C', 'D'],    //表头领标
      listTitle: '利润',
      remarks: '01',
      company: '',
      unit: '369.5',
      times: '',
      slotArray: [],
      listArray: [],
      //----------↓样式----------
      btn_grid: {
        xs: 2,
        sm: 2,
        md: 2,
        lg: 2,
        xl: 2
      },
      grid: {
        xs: 24,
        sm: 24,
        md: 12,
        lg: 8,
        xl: 8,
        xxl: 8
      },
      isRouterAlive: true, // 强制刷新
      //----------↑样式----------
      dataSource: dataSource, // 数据数组
      count: 2, // 添加行
      columns: [
        {
          title: '',
          dataIndex: 'id',
          width: '1%',
        },
        {
          title: '项目',
          dataIndex: 'Assets',
          width: '10%',
          scopedSlots: { customRender: 'Assets' },
        },
        {
          title: '行次',
          dataIndex: 'LineNoOne',
          width: '2%',
          scopedSlots: { customRender: 'LineNoOne' },
        },
        {
          title: '累计金额',
          dataIndex: 'FinaltermOne',
          width: '10%',
          scopedSlots: { customRender: 'FinaltermOne' },
        },
        {
          title: '本月金额',
          dataIndex: 'BeginningOne',
          width: '10%',
          scopedSlots: { customRender: 'BeginningOne' },
        }
      ],

      column: [
        {
          title: '资产',
          dataIndex: 'Assets',
          width: '10%',
        },
        {
          title: '行次',
          dataIndex: 'LineNoOne',
          width: '2%',
        },
        {
          title: '累计金额',
          dataIndex: 'FinaltermOne',
          width: '10%',
        },
        {
          title: '本月金额',
          dataIndex: 'BeginningOne',
          width: '10%',
        }
      ],
      list: ['Assets', 'LineNoOne', 'FinaltermOne', 'BeginningOne'],
      status: false, // 查询按钮隐藏
      visibles: false, // 查询弹窗隐藏
      show: true, // 设计表的隐藏
      showtow: false, // 浏览表格隐藏
      preservtion: true, // 保存按钮隐藏
      design: false, //设计按钮隐藏
      runData: [],
      runSon: [],
      runter: 0,
      dataTimes: '', // 时间
      chebox: '', //弹窗复选按钮
      nvmu: false,
      top: '', // 右键菜单坐标
      left: '', // 右键菜单坐标
      newData: [],
      databases: { 'accountPeriod': "0", 'type': 2 }, //默认时间
      thisClickId: null,
      currentIndexTable: null,     //当前点击的行下标
      allList: [], // 初始保存数据
      listNumber: 0,  //获取列表行数
      singlestr: '', // 获取单个数据
      newtables: '',
      unm: 0,
      thisRunData: [],
      Illiquid: '', // 非流动资产合计
      Totalassets: '', // 资产总合计
      TotalEquity: '', // 所有者权益合计
      total: '', //总计
      rundata: '',
      rouDatas: [],
      Trademark: '', //单元格标识
      Rowvalue: '', //单元格公式值
      // 右键菜单事件
      customClick: (item, index) => ({
        on: {
          contextmenu: (e) => {//右键事件
            e.preventDefault();
            this.openMenu(e);
            // console.log('右键点击的', index);
            this.thisClickId = index;
          },
          click: () => {
            this.currentIndexTable = index;
            // console.log('当前点击的行下标/列', this.currentIndexTable)
          }
        },
      }),
    }

  },
  created () {
    this.slotArray = [];
    this.columns.forEach(item => {
      if (item.scopedSlots) {
        this.slotArray.push(item.scopedSlots.customRender)
      }
    });

    // 获取期间
    periodlist().then((stal) => {
      // 表格回显
      this.postHttp(this.databases);
    })


  },
  // 获取页面事件，对右键菜单进行显示隐藏
  watch: {
    nvmu (value) {
      if (value) {
        document.body.addEventListener("click", this.closeMenu);
      } else {
        document.body.removeEventListener("click", this.closeMenu);
      }
    }

  },

  methods: {

    // 表头行标显示 列 A1 A2
    trademark (value) {
      let topname = ['Assets', 'LineNoOne', 'FinaltermOne', 'BeginningOne', 'Liabilities', 'LineNoTow', 'FinaltermTow', 'BeginningTow'];
      let toptable = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H'];
      let FormulaList = [];
      this.Rowvalue = '';
      for (let k in topname) {
        if (value[0] === topname[k]) {
          this.Trademark = toptable[k] + (Number(value[1]) + 1);
          getAssetsLiabilities(this.databases).then((rst) => {
            for (let i in rst.data) {
              if (rst.data[i].columns === toptable[k] && rst.data[i].line === (Number(value[1]) + 1)) {
                if (rst.data[i].formula !== null && rst.data[i].formula !== "") {
                  if (rst.data[i].formula[0] == '=') {
                    this.Rowvalue = rst.data[i].formula;
                  } else {
                    this.Rowvalue = '=' + rst.data[i].formula;
                  }
                }
                getFormulaList({ 'alId': rst.data[i].id }).then((row) => {
                  FormulaList = [];
                  for (let k in row.data) {
                    FormulaList.push(row.data[k].accountingName + (row.data[k].operator === 1 ? '+' : '-') +
                      (row.data[k].accessRule === 1 ? '余额'
                        : row.data[k].accessRule === 2 ? '本级借方余额'
                          : row.data[k].accessRule === 3 ? '本级贷方余额'
                            : row.data[k].accessRule === 4 ? '末级借方余额'
                              : row.data[k].accessRule === 5 ? '末级贷方余额'
                                : '其他'
                      ));
                    this.Rowvalue = '=' + FormulaList;
                  }
                })
              }
            }
          })
        }
      }
    },

    // 用户输入公式计算
    rowdata (count, data) {
      let total = [];
      let son = '';
      let sum = '';
      let strall = /0|1|2|3|4|5|6|7|8|9|a|b|c|d|e|f|g|h|i|j|k|l|m|n|o|p|q|r|s|t|u|v|w|x|y|z|A|B|C|D|E|F|G|H|I|J|K|L|M|N|O|P|Q|R|S|T|U|V|W|X|Y|Z/;
      let result = /×|-|÷|[+]/;
      let runList = []; // 符号
      let tobList = []; // 位数
      runList = count.formula.split(strall);
      tobList = count.formula.split(result);
      son = runList.filter((tiem) => tiem !== '')
      // console.log(tobList)
      //       console.log(son)
      //  console.log(data)
      for (let i in data) {
        for (let k in tobList) {
          if (tobList[k].toUpperCase() === data[i].columns + data[i].line) {
            total.push(data[i].value)
          }
        }
      }
      if (total.length !== 1) {
        for (let i = 0; i < total.length; i++) {
          sum += total[i];
          if (i < son.length) {
            sum += son[i];
          }
        }
        return eval(sum)
      } else {
        return total[0]
      }

    },

    // 回显表格
    postHttp (Times) {
      getAssetsLiabilities(Times).then((rst) => {
        let strlength = 0;
        let count = [];
        let stal = [];
        this.listArray = [];
        this.allList = [];
        let reg = /[a-zA-Z]+/i;

        for (let obj = 0; obj < rst.data.length; obj++) {
          if (rst.data[obj]['valueType'] == 3 && rst.data[obj]['type'] == 2 && rst.data[obj]['formula'] !== null) {
            // console.log(rst.data[obj].formula)
            if (rst.data[obj].formula[0] == '=') {
              rst.data[obj].formula = rst.data[obj].formula.substring(1,);
            }
            count.push(rst.data[obj])
          }
        }
        for (let i in count) {
          if (!reg.test(count[i].formula)) { // 判断是否有字符串中是否有字母 
            stal.push(eval(count[i].formula));
          } else {
            stal.push(this.rowdata(count[i], rst.data));
          }
        }
        for (let k in count) {
          count[k].value = stal[k];
        }

        for (let index = 0; index < rst.data.length; index++) {
          if (rst.data[index].columns == "A" && rst.data[index].type == 2) {
            strlength++;
            this.company = rst.data[0].companyName;
          }
        }

        if (strlength === 0) {
          strlength = 30;
        }
        this.listNumber = strlength;
        let newdataSource = [];
        for (let j = 1; j <= strlength; j++) {
          let item = {};
          this.runter++;
          if (this.runter == 9) {
            this.runter = 0;
          }
          for (let i = 0; i < rst.data.length; i++) { // 数据循环
            if (rst.data[i].type == 2) {
              this.newData[i] = rst.data[i];
              for (let k = 0; k < this.topLists.length; k++) {  // 表头循环，拼接数据
                if (rst.data[i].line == j && rst.data[i].columns == this.topLists[k]) {
                  item[this.list[k]] = rst.data[i].value;
                  item[rst.data[i].columns + 'id'] = rst.data[i].id;
                }
              }
            }
          }
          item['id'] = j;
          newdataSource.push(item);
        }
        for (let i in rst.data) {
          if (rst.data[i].type == 2) {
            this.allList.push(rst.data[i]);
          }
        }
        this.dataSource = newdataSource;
        this.reload();
      })

    },

    //显示右键菜单
    openMenu (e) {
      var x = e.pageX - 250;
      var y = e.pageY - 40;
      this.top = y;
      this.left = x;
      this.nvmu = true;
    },

    //隐藏右键菜单
    closeMenu () {
      this.nvmu = false;
    },

    //新增数据
    handleAdd (line) {
      const { count, dataSource } = this;
      this.listNumber++;
      this.$nextTick(() => {
        this.dataSource.splice(this.dataSource.length, 0, { 'id': this.listNumber, 'Assets': '', 'LineNoOne': '', 'FinaltermOne': '', 'BeginningOne': '', 'Liabilities': '', 'LineNoTow': '', 'FinaltermTow': '', 'BeginningTow': '', });
      })

      console.log('新增行：', this.dataSource)
    },

    //删除整行
    handleDelete () {
      let _this = this;
      let numberId = this.thisClickId;
      let staldata = this.allList;
      let suarray = []; // 获取被选中行
      let souarray = [];  // 获取未被选中行
      console.log('行', numberId);
      this.$confirm({
        title: "确认",
        content: (
          <span>
            您确定要{<span style="color:red;">删除</span>}该记录吗？
          </span>
        ),
        onOk () {
          let dataSource = [..._this.dataSource];
          // 数据分类
          for (let s = 0; s < staldata.length; s++) {
            if (staldata[s].line === numberId + 1 && staldata[s].type === 2) {
              souarray.push(staldata[s]); // 选中
            } else {
              suarray.push(staldata[s]);  // 未选中
            }
          }
          console.log('选中', souarray)
          console.log('未选中', suarray)
          // 下标修改
          for (let items = 0; items < suarray.length; items++) {
            if (suarray[items].line > 1) {
              suarray[items].line = suarray[items].line - 1;
            }
          }
          if (suarray.length === 0) {
            suarray.push({ 'type': 2 })
          }
          console.log(suarray)
          save(suarray).then((rst) => {
            if (rst.code == 200) {
              setTimeout(() => {
                _this.$message.success(`已删除`);
                _this.postHttp(_this.databases);
              })
            } else {
              _this.$message.warning(`系统异常请联系管理员!`)
            }
          })
          if (dataSource.length - 1 > 9) {
            _this.dataSource = dataSource.filter((item, index) => index !== numberId);
          } else {
            for (let i = 0; i < dataSource.length; i++) {
              if (i === numberId) {
                for (const key in dataSource[i]) {
                  if (key != 'number') {
                    dataSource[i][key] = ""
                  }
                }
              }
            }
            _this.dataSource = dataSource;
          }
          // _this.reload();

        },
        onCancel () { },
      });
      // this.reload();  

    },

    //强制刷新表格
    reload () {
      this.isRouterAlive = false;
      this.$nextTick(function () {
        this.isRouterAlive = true;
      });
    },

    // 表格切换
    gettabList () {
      this.showtow = false;
      this.show = true;
      this.status = false;
      this.preservtion = true;
      this.design = false;
    },

    // 浏览
    browse () {
      this.showtow = true;
      this.show = false;
      this.status = true;
      this.preservtion = false;
      this.design = true;
    },

    //打印
    printOrder () {
      this.$print(this.$refs.print);
    },

    //业务时间改变
    onChangeBusinessDate (e, v) {
      this.dataTimes = v.substr(5, 2);
      // console.log(this.dataTimes)
      this.times = v;
      // this.dataTimes = v;
    },
    // 查询弹窗关闭
    handleCancel (e) {
      this.visibles = false;
    },
    // 查询弹窗显示
    showModal () {
      this.visibles = true;
    },
    // 查询
    handleOk (e, v) {
      let data = { 'accountPeriod': this.dataTimes, 'chebox': this.chebox, 'type': 2 }
      console.log(data)
      if (this.postHttp(data)) {
        this.$message.error('查询失败请联系管理员');
        return;
      } else {
        this.loading = true;
        setTimeout(() => {
          this.$message.success(`查询完成`);
          this.visibles = false;
          this.loading = false;
        });
        return;
      }
    },

    // 获取参数
    onCellChange (index, dataIndex, value) {
      const dataSource = [...this.dataSource];
      let i = 0;
      let topname = ['Assets', 'LineNoOne', 'FinaltermOne', 'BeginningOne', 'Liabilities', 'LineNoTow', 'FinaltermTow', 'BeginningTow'];
      let toptable = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H'];
      let userid = ['Aid', 'Bid', 'Cid', 'Did', 'Eid', 'Fid', 'Gid', 'Hid'];
      this.listArray = [];
      let reg = /[\u4e00-\u9fa5]+/g;
      const target = dataSource.find((item, index) => index === index);
      // console.log('this is 行：', index); // 行
      // console.log((value)); // 值
      // console.log('this is 列', dataIndex); //列
      // console.log('th', this.dataSource); //列

      // 组装表格数据 
      if (value !== undefined) {
        while (i != this.dataSource.length) {
          if (Number(this.dataSource[i].id) - 1 == index) { // 确定行
            for (let j = 0; j < topname.length; j++) {
              if (topname[j] === dataIndex) {
                if (topname[j] === 'FinaltermOne' || topname[j] === 'BeginningOne' || topname[j] === 'FinaltermTow' || topname[j] === 'BeginningTow') {
                  if (value !== undefined) {
                    let uon = '';
                    if (typeof (value) !== 'number') {
                      uon = value.substring(0, 1)
                    }
                    if (reg.test(value) === true) {
                      this.$message.warning(`请输入数字和运算符号`);
                      this.postHttp(this.databases);
                    } else if (uon === '=') {
                      const data = {
                        'formula': value,
                        'columns': toptable[j],
                        'line': (Number(index) + 1),
                        'valueType': 3,
                        'type': 2,
                        'id': this.dataSource[i][userid[j]]
                      };
                      this.listArray.push(data);
                      console.log(this.listArray)
                    } else {
                      for (let obj in this.allList) {
                        if (this.dataSource[i][userid[j]] === undefined) {
                          const data = { // 新添加单元格
                            'value': value,
                            'columns': toptable[j],
                            'line': (Number(index) + 1),
                            'valueType': 1,
                            'type': 2,
                          };
                          this.listArray.push(data);
                        }
                        if (this.allList[obj].id === this.dataSource[i][userid[j]]) { // 确定当前选定数据
                          if (this.allList[obj].value !== value) {  // 判断用户是否修改公式单元
                            const data = {
                              'value': value,
                              'formula': '',
                              'columns': toptable[j],
                              'line': (Number(index) + 1),
                              'valueType': 1,
                              'type': 2,
                              'id': this.dataSource[i][userid[j]]
                            };
                            this.listArray.push(data);
                          }
                        }
                      }
                    }
                  }
                } else {
                  const data = {
                    'value': value,
                    'columns': toptable[j],
                    'line': (Number(index) + 1),
                    'valueType': 1,
                    'type': 2,
                    'id': this.dataSource[i][userid[j]]
                  };
                  this.listArray.push(data);
                }
              }
            }
          }
          i++;
        }
        //去重

        if (this.listArray.length !== 0) {
          for (let i = 0; i < this.allList.length; i++) {
            if (this.allList[i].line === this.listArray[0].line && this.allList[i].columns === this.listArray[0].columns && this.allList[i].type === 2) {
              this.allList.splice(i, 1)
            }
          }
          this.allList.push(this.listArray[0]);
        }
      }

    },

    // 获取子组件数据
    runDataTale (top) {
      console.log(this.allList)
      let result = [];
      let runset = ['FinaltermOne', 'BeginningOne'];
      let lielist = ['C', 'D', 'G', 'H'];
      this.thisRunData = top;
      for (let i = 0; i < top[0].length; i++) {
        result.push({
          'accessRule': top[0][i].accessRule,
          'accountingId': top[0][i].accountingId,
          'accountingName': top[0][i].accountingName,
          'operator': top[0][i].operator,
          'uid': top[0][i].uid,
          'id': top[0][i].id,
          'type': 2,
        });
      }
      for (let index = 0; index < this.thisRunData[0].length; index++) {
        for (let k = 0; k < runset.length; k++) {
          if (runset[k] == this.thisRunData[0][index].col) {
            const data = {
              'value': '',
              'columns': lielist[k],
              'line': Number(this.thisRunData[0][index].doindex) + 1,
              'valueType': 2,
              'assetsLiabilitiesFormulas': result,
              'type': 2,
            };
            this.allList.push(data);
          }
        }
      }

    },

    // 保存
    gettabListq () {
      console.log('this is lastData', this.allList)
      save(this.allList).then((rst) => {
        this.allList = [];
        if (rst.code == 200) {
          setTimeout(() => {
            this.$message.success(`保存成功`);
          })
          this.postHttp(this.databases);

        }
      })
      this.reload();
    },



  },
};
</script>
<style lang="less">
  @import '~@/style/purchase/voucher.less';
  .credentials-wrapper {
    padding: 10px;
    height: auto;
    overflow-y: auto;
    font-size: 14px;
    min-height: 350px;
    .date-tp {
      text-align: center;
      margin-bottom: 10px;
    }
    .footer-tp {
      text-align: center;
      margin-top: 10px;
    }

    .text-name {
      padding-bottom: 5px;
    }
    .subsidiary {
      border: 1px solid #cacaca;
      text-align: center;
      display: flex;
      .sub-title {
        flex: 0 0 26px;
        padding-top: 8px;
        border-right: 1px solid #cacaca;
      }
      .sub-content {
        flex: 1;
        text-align: left;
        .sub-list {
          border-bottom: 1px solid #cacaca;
          line-height: 32px;
          .ant-col {
            padding-left: 20px;
          }
        }
        .sub-list:last-child {
          border-bottom: none;
        }
      }
    }
    .total-box {
      border-left: 1px solid #cacaca;
      border-right: 1px solid #cacaca;
      border-bottom: 1px solid #cacaca;
      display: flex;
      line-height: 32px;
      text-align: center;
      font-size: 14px;
      .total-title {
        width: 77.2%;
        border-right: 1px solid #cacaca;
        box-sizing: content-box;
      }
      .total-borrow {
        width: 11.4%;
        border-right: 1px solid #cacaca;
      }
      .total-loan {
        width: 11.4%;
      }
    }
    label:not(.form-check-label):not(.custom-file-label) {
      font-weight: normal;
    }
    .bills-box-header {
      display: flex;
      justify-content: space-around;
      .filter {
        display: table;
        width: 246px;
        margin-bottom: 5px;
        .filter-label {
          display: table-cell;
          font-weight: normal;
          max-width: 160px;
          line-height: 32px;
          white-space: nowrap;
          vertical-align: bottom;
          text-overflow: ellipsis;
          overflow: hidden;
        }
        .filter-control {
          display: table-cell;
          width: 100%;
        }
      }
    }
    .ant-input-group-addon {
      border: 0px;
    }
  }

  .toplist {
    text-align: center;
  }

  .company-span-one {
    float: left;
  }

  .company-span-tow {
    float: right;
  }
  .solto {
    .ant-table-bordered .ant-table-tbody > tr > td,
    .ant-table-bordered .ant-table-thead > tr > th {
      // border: 1px solid #cccccc;
    }
  }
  .tableactive {
    width: 3%;
  }
  .tableactives {
    width: 3%;
  }
  .tableactiv {
    width: 2%;
  }
  .publictableactive {
    width: 15.33333%;
  }
  .tablePos {
    width: 75%;
    height: 100%;
    /* border: 1px solid red; */
    text-align: center;
    // margin: auto;
  }
  .formula {
    width: 100%;
    border: 1px solid #cacaca;
    border-bottom: 0;
    height: 31px;
    input {
      width: 100%;
      padding-top: 4px;
      border: 0;
      padding-left: 10px;
      outline: none;
      background-color: #fff;
    }
    div {
      float: left;
    }
  }
  .formuladiv {
    clear: both;
  }
  .formulaone {
    width: 15%;
    height: 30px;
  }
  .formulatow {
    width: 13%;
    height: 30px;
    padding-top: 4px;
    background-color: #eee;
    border: 1px solid #cacaca;
    border-top: 0;
    border-bottom: 0;
    border-top-left-radius: 30px;
    border-bottom-left-radius: 30px;
    //  border:1px solid black
  }
  .formulafreen {
    width: 72%;
    height: 30px;
    // border:1px solid black
  }
</style>
